package concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author 26029
 * @date 2025/4/25
 * @description
 */
public class LearnThread {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Thread t1 = new Thread(new RunnableThread());
        FutureTask<String> ft = new FutureTask<>(new CallableThread());
        Thread t2 = new Thread(ft);
        MyThread t3 = new MyThread();
        t1.start();
        t2.start();
        System.out.println(ft.get());
        t3.start();
    }
}

class RunnableThread implements Runnable {
    @Override
    public void run() {
        System.out.println("runnable");
    }
}

class CallableThread implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("callable");
        return "callable returned";
    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("MyThread");
    }
}